import random
def guess_number():

    money=5000
    print("欢迎来到数字游戏")
    print(f"现在拥有{money}个金币")
    while money > 0:
        target_number = random.randint(1, 100)
        print("我已经想好一个数字了")
        while money >0 :
            try:
                user_number = int(input("请输入一个数字:"))
                if user_number > target_number:
                    money = money - 500
                    print("猜大了，往小一点猜")
                    print(f"当前金币：{money}")
                elif user_number < target_number:
                    money = money - 500
                    print("猜小了，往大猜一点")
                    print(f"当前金币：{money}")
                else:
                    print("恭喜你猜对了")
                    money = money + 3000
                    print(f"当前金币：{money}")
                    break
            except ValueError():
                print("请输入一个整数")

        if money <=0:
            print("很遗憾，你已经没有金币了，游戏结束！")
            break

        continue_game = input("是否继续游戏？(输入 'yes' 继续，其他退出): ").strip().lower()
        if continue_game != 'yes':
            print("游戏退出，感谢参与！")
            break



guess_number()
